package com.juhuixing.common.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * 所有标记为{@link  org.springframework.web.bind.annotation.RequestBody}的类的抽象父类，
 * Created by ioun on 2016/11/29.
 */

@ApiModel
@Data
public abstract class AbstractRequest {
    @ApiModelProperty("页码(不传递默认为1)")
    private Integer pageNo=1;
    @ApiModelProperty("每页显示的记录数(不传递默认为10)")
    private Integer pageSize=10;

    private static final Map<String,Field[]> fields = new HashMap<>();

    public AbstractRequest(){
        String simpleName = this.getClass().getSimpleName();
        Field[] field = fields.get(simpleName);
        if(field==null){
            fields.put(simpleName,this.getClass().getDeclaredFields());
        }
    }

    public static Field[] getFields(String key) {
        return fields.get(key);
    }
}
